#!/bin/sh
# $Id: libproxy_test_envvar.test 298 2008-12-17 05:34:50Z dominique.leuenberger $

result1_ok="http://1.2.3.4:1234"
result2_ok="direct://"
testurl1="http://code.google.com"
testurl2="http://www.google.com"
proxy_bin="$( test -x src/bin/proxy && echo src/bin/proxy || which proxy)"
pac_url="file://$(pwd)/test.d/libproxy_test_pac_file.test.pac"

if [ -x $proxy_bin ]; then
    result1=$(PX_CONFIG_ORDER=config_envvar PX_MODULE_BLACKLIST="pacrunner_*" PX_MODULE_WHITELIST="pacrunner_webkit" http_proxy="pac+$pac_url" $proxy_bin $testurl1)
    result2=$(PX_CONFIG_ORDER=config_envvar PX_MODULE_BLACKLIST="pacrunner_*" PX_MODULE_WHITELIST="pacrunner_webkit" http_proxy="pac+$pac_url" $proxy_bin $testurl2)
else
    result="N/A"
fi

echo 'name="test_pacrunner_webkit"'
if [ "$result1" = "$result1_ok" -a "$result2" = "$result2_ok" ]; then
  echo pass=True
else
  echo pass=False
  echo "reason='$proxy_bin returned $result1 and $result2 instead of $result1_ok and $result2_ok'"
fi
